<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){//
    	$acts = M('activity');
//		$limit = 3;
		$p = I('p');
		$limit = C('INDEX_ACTIVITY_PAGE');
		$where = 'status = 1 and aetime >='.time();
		$lwhere = 'status =1 and atime <='.time().' and aetime >='.time();
		//普通活动
		$act = $acts->where($where)->order(' id desc ')->limit($limit)->page($p)->select();
		//轮播图活动
		$lact = M('lb_activity')->where($lwhere)->order('numorder asc')->select();
		$count = $acts->where($where)->count();
		$max_page = $count/$limit;
		if(!$p){//第一页
			$p=1;
			$situation = 'first';//首页
		}else{
			if($p >= $max_page){
				$situation = 'last';//末页
			}else if($p==1){
				$situation = 'first';//首页
			}else{
				$situation = 'middle';//中间页
			}
		}
		if($count<=$limit){//一共不到20条信息
			$situation = 'justone';
		}
		
		$this->p=$p;//当前页传去页面
		$this->situation = $situation;//当前页的情况
		$this->act=$act;
		$this->lact=$lact;
		$this->meta_title = '十五分钟音乐计划';
    	$this->display();
    }
	
}